package com.info3k.client.components;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.info3k.client.Info3K;

public class ContentBox extends Composite{

	private HTML glass = new HTML();
	
	public VerticalPanel panel = new VerticalPanel();
	
	public FlowPanel content = new FlowPanel();
	
	public Button closeButton = new Button(Info3K.msgs.close());
	
	public FlowPanel footer = new FlowPanel();
	
	public HTML header = new HTML();
	
	public HorizontalPanel head = new HorizontalPanel();
	public HorizontalPanel headerLeft = new HorizontalPanel();
	public HorizontalPanel headerRight = new HorizontalPanel();
	
	public void center() {
		RootPanel.get("right_section").clear();
		RootPanel.get("right_section").add(this);
	}
	
	public void hide() {
	}
	
	public void setText(String text){
		header.setHTML("<h1>" + text + "</h1>");
	}
	
	public ContentBox(){
		initWidget(panel);
		glass.getElement().setId("glass");
		glass.setStylePrimaryName("rxf-glass");
		panel.setWidth("100%");
		content.setWidth("100%");
		content.setHeight("100%");
		footer.getElement().getStyle().setProperty("margin", "10px 0 0 0");
		
		panel.add(head);
		panel.add(new HTML("<div class=\"h_line\"></div>"));
		head.setWidth("100%");
		head.add(headerLeft);
		head.setCellWidth(headerLeft, "60%");
		head.setCellWidth(headerRight, "40%");
		head.add(headerRight);
		
		headerRight.setWidth("100%");
		
		headerLeft.add(header);
		
		panel.add(content);	
		panel.add(footer);
		panel.setCellHeight(head, "10%");
		panel.setCellHeight(content, "80%");
		panel.setCellHeight(footer, "10%");
		headerLeft.setCellHorizontalAlignment(header, HorizontalPanel.ALIGN_LEFT);
		panel.setCellHorizontalAlignment(footer, HorizontalPanel.ALIGN_RIGHT);
		
		closeButton.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				hide();
			}
		});
	}
	
	public HTML getGlass() {
		return glass;
	}
	
	public void setGlass(HTML glass) {
		this.glass = glass;
	}
}
